package com.wkm.chainchain.pbft.node;

import cn.hutool.core.collection.ConcurrentHashSet;

import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;

public class MsgCollection {
    private static final MsgCollection msgCollection = new MsgCollection();


    // 空的构造方法
    private MsgCollection() {
    }

    public static MsgCollection getInstance() {
        return msgCollection;
    }

    /**
     * 预准备阶段 目前不需要此集合
     */
    public static final Set<Long> votePrePrepareSet = new ConcurrentHashSet<>();

    /**
     * 准备阶段
     */
    public static final Map<Long, Set<Integer>> votePrepareMap = new ConcurrentHashMap<>();

    /**
     * 准备阶段成功池
     */
    public static final Set<Long> preparedSet = new ConcurrentHashSet<>();

    /**
     * 提交阶段
     */
    public static final Map<Long, Set<Integer>> voteCommitMap = new ConcurrentHashMap<>();

    /**
     * 提交阶段成功池
     */
    public static final Set<Long> CommittedSet = new ConcurrentHashSet<>();

    /**
     * 返回阶段
     */
    public static final Map<Long, Set<Integer>> voteReplyMap = new ConcurrentHashMap<>();

    /**
     * 返回阶段成功池
     */
    public static final Set<Long> repliedSet = new ConcurrentHashSet<>();

    /**
     * 达成共识的列表
     */
    public static final List<Long> reachedConsensusMsgList = new CopyOnWriteArrayList<>();

}
